home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 1.iso / ARGONET / PD / PROGRAMMING / DESKLIBC / SOURCES.ZIP / DeskLib / !DLSources / Libraries / Resource / c / LoadSprite < prev    next >
Text File  |  1995-04-11  |  3KB  |  69 lines

  1. /*
  2.     ####             #    #     # #
  3.     #   #            #    #       #          The FreeWare C library for
  4.     #   #  ##   ###  #  # #     # ###             RISC OS machines
  5.     #   # #  # #     # #  #     # #  #   ___________________________________
  6.     #   # ####  ###  ##   #     # #  #
  7.     #   # #        # # #  #     # #  #    Please refer to the accompanying
  8.     ####   ### ####  #  # ##### # ###    documentation for conditions of use
  9.     ________________________________________________________________________
  10.  
  11.     File:    Resource.LoadSprite.c
  12.     Author:  Copyright © 1994 Lenny
  13.     Version: 0.01 (18 Nov 1994)
  14.     Purpose: Creates a user sprite area, and loads the application's
  15.              resource sprite file ("Sprites") into this area.
  16.     History: 0.01 (18 Nov 94) : Added 'Resource_LoadSprites()'
  17.  
  18. */
  19.  
  20. /* --- LOAD HEADERS ------------------------------------------------------ */
  21.  
  22. /* --- DeskLib ----------------------------------------------------------- */
  23. #include "DeskLib:Error.h"             /* Error despatcher                 */
  24. #include "DeskLib:File.h"              /* Low level file handling          */
  25. #include "DeskLib:Resource.h"          /* Handles finding resource files   */
  26. #include "DeskLib:Sprite.h"            /* Sprite handling                  */
  27.  
  28. /* --- CLib -------------------------------------------------------------- */
  29. #include <stdlib.h>      /*  Standard library routines                     */
  30. #include <string.h>      /*  String manipulation routines                  */
  31.  
  32. /* === FUNCTION DEFINITIONS ============================================== */
  33.  
  34. /*  Global variable for a pointer to the resource user sprite area.
  35.  *  Defaults to the Wimp sprite pool.
  36.  */
  37.  
  38.  
  39. sprite_area resource_sprites = (sprite_area) 1;
  40.  
  41. #ifdef _DLL
  42. sprite_area *Resource__Ref_sprites( void) { return &resource_sprites; }
  43. #endif
  44.  
  45.  
  46.  
  47. extern void Resource_LoadSprites(void)
  48. {
  49.   char                  filename[256];
  50.   int                   filesize;
  51.  
  52.   if (resource_sprites != (sprite_area) 1)
  53.     return;   /* The resources have already been loaded?! */
  54.  
  55.   strcpy(filename, resource_pathname);  strcat(filename, "Sprites");
  56.   filesize = File_Size(filename);
  57.   if (filesize == 0) {
  58.     Error_ReportFatal(1, "'Sprites' resource file not found");
  59.   }
  60.   resource_sprites = malloc(filesize + 16);
  61.   resource_sprites->areasize = filesize + 16;
  62.   resource_sprites->firstoffset = 16;
  63.   Sprite_InitArea(resource_sprites);
  64.   Sprite_Load(resource_sprites, filename);
  65.  
  66. }
  67.  
  68. /***************************************************************************/
  69.